// 最近主力增减仓趋势
import { defineComponent, ref } from "vue";
import { dxget } from "../../util/index";
export default defineComponent({
  props: {
    code: {
      type: String,
    },
  },
  setup(props) {
    let tableData = ref([]);
    let columns = [
      {
        title: "名称",
        key: "name",
        align: "center",
      },
      {
        title: "净流入(万元)",
        key: "lr",
        align: "center",
      },
      {
        title: "净占比(%)",
        key: "zb",
        align: "center",
      },
    ];
    const rowClassName = (row, index) => {
      if (row.lr >= 0) {
        return "red";
      }
      return "ls";
    };
    const initData = async () => {
      let kjjhe: any = await dxget("dc/getZDYLBData", {
        code: props.code,
      });
      tableData.value = kjjhe.data;
    };

    initData();
    return () => (
      <>
        <n-card title="最近主力增减仓趋势 ">
          <div class="table-tbody-s">
            <n-data-table
              size="small"
              row-class-name={rowClassName}
              max-height="660"
              columns={columns}
              data={tableData.value}
              single-line={false}
            />
          </div>
        </n-card>
      </>
    );
  },
});
